/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package threading_webserver;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.event.WindowEvent;
import javax.swing.*;

/**
 *
 * @author Koen
 */
public class ServerView extends JFrame {
  JPanel jPanel1 = new JPanel();
  JScrollPane jScrollPane1 = new JScrollPane();
  JTextArea jTextArea2 = new JTextArea();
  String name = "Server";

  public ServerView(String name) throws Exception {
      this.name = name;
      createGUI(name);
  }
  
  
  private void createGUI(String title) throws Exception {
    jTextArea2.setBackground(Color.BLACK);
    jTextArea2.setForeground(Color.WHITE);
    jTextArea2.setBorder(BorderFactory.createLoweredBevelBorder());
    jTextArea2.setToolTipText("");
    jTextArea2.setEditable(false);
    jTextArea2.setColumns(71);
    jTextArea2.setRows(34);
    
    this.setTitle(name);
    
    this.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        this_windowClosed(e);
      }
    });
    
    //add panels to ViewPort
    jScrollPane1.getViewport().add(jTextArea2);
    jPanel1.add(jScrollPane1);
    this.getContentPane().add(jPanel1, BorderLayout.WEST);

    this.setVisible(true);
    this.setSize(800, 590);
    this.setResizable(false);
    
    //make sure it is drawn
    this.validate();
  }

  void this_windowClosed(WindowEvent e) {
    System.exit(1);
  }

  //get messages from the server to the window
  public void send_message_to_window(String s) {
    jTextArea2.append(s);
  }
}
